package com.learn.learnredis.jedis.socket;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;
import java.util.LinkedList;

/**
 * @author wangxing
 * @version 2020/7/21 7:02 Administrator
 */
public class C10kClient {
    public static void main(String[] args) {
        LinkedList<SocketChannel> client = new LinkedList<>();
        //目标地址和目标端口
        InetSocketAddress serverAddr = new InetSocketAddress(80);
        for (int i = 10000; i < 65000 ; i++) {
            try {
                SocketChannel channel1 = SocketChannel.open();
//                SocketChannel channel2 = SocketChannel.open();
                //绑定本机的ip和端口
                channel1.bind(new InetSocketAddress(i) );
                //去连接目标地址
                channel1.connect(serverAddr);
                client.add(channel1);
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    }
}
